<!DOCTYPE html>
<html class="x-admin-sm">
<head>
  <meta charset="UTF-8">
  <title>欢迎页面-X-admin2.2</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
  <link rel="stylesheet" href="/static/css/font.css">
  <link rel="stylesheet" href="/static/css/xadmin.css">
  <script src="/static/lib/layui/layui.js" charset="utf-8"></script>
  <script type="text/javascript" src="/static/js/xadmin.js"></script>
  <!--[if lt IE 9]>
  <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
  <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
  <![endif]-->
</head>
<body>
<div class="layui-fluid">
  <div class="layui-row layui-col-space15">
    <div class="layui-col-md12">
      <div class="layui-card">
        <div class="layui-card-body ">
          <form class="layui-form layui-col-space5">
            <div class="layui-inline layui-show-xs-block">
              <input type="text" name="order_sn"  placeholder="请输入订单号" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-inline layui-show-xs-block">
              <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
            </div>
          </form>
        </div>

        <div class="layui-card-header">

          <button class="layui-btn" onclick="xadmin.open('添加出库单','addorder?id={$oid}',800,600)"><i class="layui-icon"></i>添加批次</button>
        </div>


      </div>
    </div>
  </div>
</div>
<div class="layui-card-body layui-table-body layui-table-main">
  <table class="layui-table layui-form">
    <thead>
    <tr>
      <th>批次名称</th>
      <th>创建时间</th>
      <th>确认时间</th>
      <th>选择供应商</th>
      <th>状态</th>
      <th>操作</th>
    </tr>
    </thead>
    <tbody>
    {volist name="list" id="v"}
    <tr>
      <td>{$v.name}</td>
      <td>{$v.time|date='Y-m-d H:i:s'}</td>
      <td>{if $v.send_time}{$v.send_time|date='Y-m-d H:i:s'}{/if}</td>
      <td>{$v.c_name}</td>
      <td>
        {if $v.status == 1}
        <span class="layui-btn layui-btn-normal layui-btn-mini">等待确认商品</span>
        {elseif $v.status==2}
        <span class="layui-btn">待确认</span>
        {/if}
      </td>
      <td class="td-manage">

        {if $v.status==1}
        <button type="button" class="layui-btn layui-btn-primary" onclick="changeOrder({$v.id},2)">确认入库单</button>
        <button type="button" class="layui-btn layui-btn-primary" onclick="xadmin.open('编辑','changegoods?oid={$oid}&id={$v.id}',)">管理商品</button>
        {/if}

        {if $v.status==2}
          <a type="button" href="/index/Ordertimes/inorder?times_id={$v.id}" class="layui-btn">入库单管理</a>
        {/if}

      </td>
    </tr>
    {/volist}
    </tbody>
  </table>
</div>
<script>
  layui.use(['laydate','form'], function(){
    var laydate = layui.laydate;
    var  form = layui.form;


    // 监听全选
    form.on('checkbox(checkall)', function(data){

      if(data.elem.checked){
        $('tbody input').prop('checked',true);
      }else{
        $('tbody input').prop('checked',false);
      }
      form.render('checkbox');
    });

    //执行一个laydate实例
    laydate.render({
      elem: '#start' //指定元素
    });

    //执行一个laydate实例
    laydate.render({
      elem: '#end' //指定元素
    });


  });
  function changeOrder(id,status){
    $.ajax({
      url:'changeOrder',
      type:'post',
      data:{id:id,status:status},
      dataType:"json",
      success:function (res) {
        if (res.code==1){
          window.location.href=""
        }else if(res.code == 2){
          layer.alert(res.msg, {
                    icon: 6
                  },
                  function() {
                    //关闭当前frame
                    xadmin.close();

                    // 可以对父窗口进行刷新
                    xadmin.father_reload();
                  });
        }  else{
          alert("网络错误");
        }
      }
    });
  }

  /*用户-删除*/
  function delware(id){
    layer.confirm('确认要删除吗？',function(index){
      $.ajax({
        url:'delware',
        type:'post',
        data:{id:id},
        dataType:"json",
        success:function (res) {

        }
      });
      layer.msg('已删除!',{icon:1,time:1000});
      window.location.href="";
    });
  }




</script>
</html>